package com.gpjcjl.ui.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.base.lib.SharedHelper;
import com.gpjcjl.BaseActivity;
import com.gpjcjl.BaseFragment;
import com.gpjcjl.Config;
import com.gpjcjl.R;
import com.gpjcjl.entity.SettingProfile;
import com.yanzhenjie.recyclerview.OnItemClickListener;
import com.yanzhenjie.recyclerview.SwipeRecyclerView;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * 水压检测
 */
public class SettingItem8 extends BaseActivity implements OnItemClickListener {

    @BindView(R.id.listView)
    SwipeRecyclerView listView;
    private CommonAdapter<String> adapter;
    @Override
    protected int getContentView() {
        return R.layout.fragment_item8;
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        listView.setOnItemClickListener(this);

        List<String> list = new ArrayList<>();
        list.add("合格");
        list.add("不合格");
        listView.setAdapter(adapter = new CommonAdapter<String>(mContext, R.layout.item_choose, list) {
            @Override
            protected void convert(ViewHolder holder, String o, int position) {
                holder.setText(R.id.tv, o);
                String cache = SettingProfile.getWater_gage();
                holder.setVisible(R.id.iv, o.equals(cache));
            }
        });
    }

    @Override
    public void onItemClick(View view, int position) {
        SettingProfile.setWater_gage(adapter.getDatas().get(position));
        adapter.notifyDataSetChanged();
    }
}
